use serde_derive::{Serialize, Deserialize};
use rust_admin2_common::{models::{MenuRow as ModelRow}, json::JsonPager};
use sqlx::{postgres::{PgRow}, row::Row};
use crate::common::{Pool, models::BackendModel};

#[derive(Serialize, Deserialize, Debug)]
pub struct Menu;

impl BackendModel<ModelRow> for Menu {

    const TABLE_NAME: &'static str = "menus";
    const FIELDS: &'static str = "id, parent_id, name, url, icon, is_blank, is_show, sort, level";

    fn get_row_filter(r: &PgRow) -> ModelRow {
        unfold_fields!(r, {
            id => i32,
            parent_id => i32,
            name => String,
            url => String,
            icon => String,
            is_blank => i16,
            is_show => i16,
            sort => i32,
            level => i16,
        })
    }
}

impl Menu {

    record_list!();
}
